﻿using System;
using System.Windows;
using System.Windows.Data;

namespace Kiva7.ValueConverter
{
    public class NumberNotVisibility : IValueConverter
    {
        public object Convert(object value,
                              Type targetType,
                              object parameter,
                              System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return Visibility.Visible;
            }
            if (value is double)
            {
                if ((double) value == 0)
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            if (value is int)
            {
                if ((int) value == 0)
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            return Visibility.Visible;
        }

        public object ConvertBack(object value,
                                  Type targetType,
                                  object parameter,
                                  System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}